package com.by.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.by.order.entity.OrderEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<OrderEntity> {
    // 插入订单
    int insertOrder(OrderEntity orderEntity);

    // 根据用户ID和商品ID查询订单
    OrderEntity selectOrderByUserIdAndGoodsId(@Param("userId") Long userId, @Param("goodsId") Long goodsId);

    // 更新订单状态
    int updateOrderStatus(@Param("id") Long id, @Param("status") Integer status);
    
    // 更新订单状态和支付时间
    int updateOrderStatusAndPayTime(@Param("id") Long id, @Param("status") Integer status, @Param("payTime") LocalDateTime payTime);

    // 秒杀商品时创建订单
    int createSeckillOrder(OrderEntity orderEntity);
    
    // 批量插入订单
    int batchInsert(@Param("orderList") List<OrderEntity> orderList);
}